<?php

namespace App\Admin\Controllers;

use App\Models\City;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class CityController extends Controller
{
    public function city(Request $request)
    {
        $provinceId = $request->get('q');

        return City::city()->where('p_id', $provinceId)->get(['id', DB::raw('name as text')]);
    }

    public function area(Request $request)
    {
        $cityId = $request->get('q');

        return City::area()->where('p_id', $cityId)->get(['id', DB::raw('name as text')]);
    }

}
